<?php
class My_Helper_View_Time extends Zend_View_Helper_Abstract
{
    public function time(){
        return $this;
    }
    public function dateToData($Date = "00/00/0000")//dd/mm/yyyy to yyyy-mm-dd
	{
		list($d, $m, $y) = preg_split('/\//', $Date);
		return sprintf('%04d-%02d-%02d', $y, $m, $d);
	}
    public function dateTimeToDataTime($Date = "00/00/0000 00:00:00")//dd/mm/yyyy HH:ii:ss to yyyy-mm-dd HH:ii:ss
	{
        if(strlen($Date)<10)
            $Date = "00/00/0000 00:00:00";
        list($d, $m, $y) = preg_split('/\//', $Date);
		list($y, $h) = preg_split('/(\s)/', $y);
		list($h, $i, $s) = preg_split('/:/', $h);
		return sprintf('%04d-%02d-%02d %02d:%02d:%02d', $y, $m, $d, $h, $i, $s);
	}
    public function dataToDate($Date = "0000-00-00") //yyyy-mm-dd to dd/mm/yyyy
    {
        list($y, $m, $d) = preg_split('/-/', $Date);
        return sprintf('%02d/%02d/%04d', $d, $m, $y);
    }
    public function dataTimeToDateTime($Date = "0000-00-00 00:00:00")//yyyy-mm-dd HH:ii:ss to dd/mm/yyyy HH:ii:ss
	{
        if(strlen($Date)<19)
            $Date = "0000-00-00 00:00:00";
        list($y, $m, $d) = preg_split('/-/', $Date);
		list($d, $h) = preg_split('/(\s)/', $d);
		list($h, $i, $s) = preg_split('/:/', $h);
		return sprintf('%02d/%02d/%04d %02d:%02d:%02d', $d, $m, $y, $h, $i, $s);
	}
    public function dataTimeToDateTime_2($Date = "0000-00-00 00:00:00")//yyyy-mm-dd HH:ii:ss to HH:ii dd/mm/yyyy
	{
        if(strlen($Date)<19)
            $Date = "0000-00-00 00:00:00";
        list($y, $m, $d) = preg_split('/-/', $Date);
		list($d, $h) = preg_split('/(\s)/', $d);
		list($h, $i, $s) = preg_split('/:/', $h);
		return sprintf('%02d:%02d %02d/%02d/%04d', $h, $i, $d, $m, $y);
	}
    public function dataTimeToDateTime_3($Date = "0000-00-00 00:00:00")//yyyy-mm-dd HH:ii:ss to mm//yyyy
	{
        if(strlen($Date)<19)
            $Date = "0000-00-00 00:00:00";
        list($y, $m, $d) = preg_split('/-/', $Date);
		list($d, $h) = preg_split('/(\s)/', $d);
		list($h, $i, $s) = preg_split('/:/', $h);
		return sprintf('%02d/%02d/%04d', $m, $d, $y);
	}
    public function addDate($Date = "0000-00-00", $Num) // 12/01/2012 + 3 = 15/05/2012
    {
        list($y, $m, $d) = preg_split('/-/', $Date);
        $date = mktime(0, 0, 0, $m, $d + $Num, $y);
        return date("Y-m-d",$date);
    }
}